package com.supermap.localization.util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;

import com.supermap.localization.commontypes.SampleInfo;

public class SampleInfoUtil {
    // 根据SampleInfo中的key值长度排序
    public static List<SampleInfo> sortByLengthDesc(List<SampleInfo> sampleInfos) {
        Collections.sort(sampleInfos, new Comparator<SampleInfo>() {

            public int compare(SampleInfo arg0, SampleInfo arg1) {
                return arg0.getKey().length() - arg1.getKey().length();
            }

        });
        return sampleInfos;
    }
    
    // 根据SampleInfo中的key值排序（String比较）
    public static List<SampleInfo> sortByStringDesc(List<SampleInfo> sampleInfos) {
        Collections.sort(sampleInfos, new Comparator<SampleInfo>() {

            public int compare(SampleInfo arg0, SampleInfo arg1) {
                return arg0.getKey().compareTo(arg1.getKey());
            }

        });
        return sampleInfos;
    }
    
    // 根据SampleInfo中的key值排序（String比较）
    public static List<SampleInfo> sortByStringDesc(Set<SampleInfo> sampleInfos) {
        List<SampleInfo> tmpInfos = new ArrayList<SampleInfo>(sampleInfos);
        return sortByStringDesc(tmpInfos);
    }
}
